package com.ddxcloud.movie.controller;

import com.ddxcloud.common.utils.Result;
import com.ddxcloud.movie.data.entity.Activity;
import com.ddxcloud.movie.service.ActivityService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/activity")
@Tag(name = "活动")
public class ActivityController {

    @Resource
    ActivityService activityService;

    /**
     * 根据活动类型获取活动
     * @param activityType
     * @return
     */
    @Operation(summary = "根据活动类型获取活动")
    @GetMapping("/getActivityByType")
    public Result<List<Activity>> getActivityByType(Integer activityType) {
        return Result.success(activityService.getActivityByType(activityType));
    }

    /**
     * 领券
     * @param activityId
     * @return
     */
    @Operation(summary = "领券")
    @GetMapping("/receive")
    public Result<?> receive(int activityId) {
        return Result.success(activityService.handleActivityToUser(activityId));
    }
}
